package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class Life {

    private String lifeTime;

    //构造方法
    public Life() {
        System.out.println("1:实例化[构造方法]");
    }
   //set方法
    @Value("青少年")
    public void setLifeTime(String lifeTime) {
        this.lifeTime = lifeTime;
        System.out.println("2:属性赋值[set方法]");
    }

   @PostConstruct
    public void init(){
       System.out.println("3:初始化方法执行");
    }
    @PreDestroy
    public void destroy(){
        System.out.println("5:销毁阶段:销毁之前需要执行的操作");
    }
}
